home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / b / b.lha / B / Setup < prev    next >
Encoding:
Text File  |  1988-11-24  |  11.2 KB  |  608 lines

  1. : 'Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984, 1985.'
  2.  
  3. echo "Configuration questions for the B system."
  4.  
  5. : 'Determine if echo -n works'
  6. echo -n "bleep" >.bleep
  7. if grep n .bleep >/dev/null 2>&1
  8. then
  9.     n=""
  10. else
  11.     n="-n"
  12. fi
  13. rm -f .bleep
  14.  
  15. : 'What machine?'
  16. echo " "
  17. echo $n "Figuring out what machine you have "
  18. echo $n "..."
  19. cat >machine.c <<EOF
  20. #include <stdio.h>
  21. main() {
  22. #ifdef vax
  23.     printf("vax\n");
  24. #else
  25. #ifdef pdp
  26.     printf("pdp\n");
  27. #else
  28. #ifdef PDP
  29.     printf("pdp\n");
  30. #else
  31.     printf("other\n");
  32. #endif
  33. #endif
  34. #endif
  35. }
  36. EOF
  37. cc machine.c -o machine
  38. machine=`machine`
  39. rm -f machine*
  40. echo " "
  41. case $machine in
  42. vax)
  43.     echo "This machine appears to be a VAX."
  44.     echo $n "Is this true? "
  45.     read ans
  46.     case $ans in
  47.     n*|N*|f*|F*)    machine="other"
  48.         ;;
  49.     *)    bint="bint"
  50.         ;;
  51.     esac
  52.     ;;
  53. pdp)
  54.     echo "This machine appears to be a PDP."
  55.     echo $n "Is this true? "
  56.     read ans
  57.     case $ans in
  58.     n*|N*|f*|F*)    machine="other"
  59.         ;;
  60.     *)    bint="bsmall"
  61.         ;;
  62.     esac
  63.     ;;
  64. esac
  65. case $machine in
  66. other)
  67.     echo "Your machine does not appear to be a VAX or PDP."
  68.     echo $n "Is this a small machine (less than 190K code space)? "
  69.     read ans
  70.     case $ans in
  71.     y*|Y*)    bint="bsmall"
  72.         ;;
  73.     *)    bint="bint"
  74.         ;;
  75.     esac
  76.     echo " "
  77.     echo "Since your machine may not be a VAX or PDP, you might have to edit"
  78.     echo "the configuration file for the B interpreter '$bint'."
  79.     echo "Check the remarks in b0con.h and README in ./src/$bint."
  80.     ;;
  81. esac
  82.  
  83. case $bint in
  84. "bsmall")
  85.     echo " "
  86.     echo "Since you have a small system, we can only use the old"
  87.     echo "version of the B interpreter, named $bint."
  88.     echo "See the file ./src/bsmall/README for details."
  89.     echo " "
  90.     echo "The B editor is too big in its full glory."
  91.     echo "Therefore all kinds of features will be turned off in an"
  92.     echo "attempt to make it fit."
  93.     echo "See ./src/bed/feat.h for details."
  94.     ;;
  95. esac
  96.  
  97. : 'What unix?'
  98. echo " "
  99. echo $n "Finding out about your brand of unix "
  100. echo $n "..."
  101. cat >unix.c <<EOF
  102. #include <stdio.h>
  103. #include <signal.h>
  104. main() {
  105. #ifdef SIGCHLD
  106. #ifdef SIGVTALRM
  107.     printf("BSD4_2\n");
  108. #else
  109.     printf("BSD\n");
  110. #endif
  111. #else
  112. #ifdef SIGCLD
  113.     printf("ATT\n");
  114. #else
  115.     printf("unknown\n"); /* Version 7 we hope ... */
  116. #endif
  117. #endif
  118. }
  119. EOF
  120. cc unix.c -o unix
  121. unix=`unix`
  122. rm -f unix*
  123.  
  124. echo " "
  125. case $unix in
  126. BSD4_2)
  127.     echo "You appear to be running Berkeley's BSD unix, version 4.2 (or later)."
  128.     echo $n "Is this true? "
  129.     read ans
  130.     case $ans in
  131.     n*|N*|f*|F*)    unix="unknown";;
  132.     esac
  133.     ;;
  134. BSD)
  135.     echo "You appear to be running Berkeley's BSD unix."
  136.     echo $n "Is this true? "
  137.     read ans
  138.     case $ans in
  139.     n*|N*|f*|F*)    unix="unknown";;
  140.     esac
  141.     ;;
  142. ATT)
  143.     echo "You appear to be running ATT's System III or System V unix."
  144.     echo $n "Is this true? "
  145.     read ans
  146.     case $ans in
  147.     n*|N*|f*|F*)    unix="unknown";;
  148.     esac
  149.     ;;
  150. esac
  151.  
  152. case $machine in
  153. pdp|other)
  154.     case $unix in
  155.     unknown)
  156.         echo $n "Are you running PWB Unix? "
  157.         read ans
  158.         case $ans in
  159.         y*|Y*)    unix="PWB";;
  160.         esac
  161.         ;;
  162.     esac
  163. esac
  164.  
  165. case $unix in
  166. unknown)
  167.     echo " "
  168.     echo "We cannot find out what type of unix you are running."
  169.     echo "See ./src/bed/unix.h, ./src/bed/feat.h, /src/$bint/README"
  170.     echo "and ./src/$bint/b0con.h in case of problems."
  171.     ;;
  172. esac
  173.  
  174. : 'Floating point arithmetic ok?'
  175. echo " "
  176. cat >float.c <<EOF
  177. #include <stdio.h>
  178. double dadd(a, b) double a, b; {
  179.     return a+b;
  180. }
  181. main() {
  182.     double a, b, c;
  183.     double dadd();
  184.     a = 3.14;
  185.     b = 2.7 * a;
  186.     c = dadd(a, b);
  187.     exit(0);
  188. }
  189. EOF
  190. cc -O float.c -o float >/dev/null 2>&1
  191. if sh 2>/dev/null <<EOF
  192.     if float
  193.     then exit 0
  194.     else exit 1
  195.     fi
  196. EOF
  197. then
  198.     echo "Your floating point seems to be alright."
  199.     fflag=""
  200. else
  201.     echo "Your C compiler seems to need a special flag for"
  202.     echo "loading (probably software) floating point routines."
  203.     echo $n "What flag is needed (default -f) "
  204.     read fflag
  205.     case $fflag in
  206.     '')    fflag="-f";;
  207.     esac
  208.     cc -O $fflag float.c -o float >/dev/null 2>&1
  209.     until sh 2>/dev/null <<EOF
  210.         if float
  211.         then exit 0
  212.         else exit 1
  213.         fi
  214. EOF
  215.     do
  216.         echo "This flag doesn't seem to work."
  217.         echo "Try again (default -f) "
  218.         read fflag
  219.         case $fflag in
  220.         '')    fflag="-f";;
  221.         esac
  222.         cc -O $fflag float.c -o float >/dev/null 2>&1
  223.     done
  224. fi
  225. rm -f float* core
  226.  
  227. : 'termio system?'
  228. if test -r /usr/include/termio.h
  229. then
  230.     termio="yes"
  231.     echo " "
  232.     echo "Termio.h found."
  233. else
  234.     termio="no"
  235.     if test ! -r /usr/include/sgtty.h
  236.     then
  237.         echo " "
  238.         echo "Neither termio.h nor sgtty.h found."
  239.         echo "See ./src/bed/unix.h in case of problems."
  240.     fi
  241. fi
  242.  
  243. : 'termcap library for B editor'
  244. echo " "
  245. echo $n "Searching for your termcap-like library routines "
  246. echo $n "... "
  247. if test -r /lib/libtermcap.a -o -r /usr/lib/libtermcap.a
  248. then
  249.     termlib="-ltermcap"
  250.     echo "termcap library found."
  251. elif test -r /usr/local/lib/libtermcap.a
  252. then
  253.     termlib="/usr/local/lib/libtermcap.a"
  254.     echo "local termcap library found."
  255. elif test -r /lib/libtermlib.a -o -r /usr/lib/libtermlib.a
  256. then
  257.     termlib="-ltermlib"
  258.     echo "termlib library found."
  259. elif test -r /usr/local/lib/libtermlib.a
  260. then
  261.     termlib="/usr/local/lib/libtermlib.a"
  262.     echo "local termlib library found."
  263. elif test -r /lib/libcurses.a -o -r /usr/lib/libcurses.a
  264. then
  265.     termlib="-lcurses"
  266.     echo "terminfo library found."
  267. elif test -r /usr/local/lib/libcurses.a
  268. then
  269.     termlib="/usr/local/lib/libcurses.a"
  270.     echo "local terminfo library found."
  271. else
  272.     : 'changed for 4.3 BSD release'
  273.     termlib="ask_it"
  274. fi
  275. while test "$termlib" = "ask_it" -o "$termlib" = "try_again"; do
  276.     case $termlib in
  277.     ask_it)
  278.         echo " "
  279.         echo "Please specify where the termcap-like routines are kept"
  280.         echo $n " (either full pathname or -lxxx option) "
  281.         ;;
  282.     try_again)
  283.         echo $n "Please try again (full pathname or -lyyy option) "
  284.         ;;
  285.     esac
  286.     read termlib
  287.     case $termlib in
  288.     -l*)
  289.         echo "Hope $termlib will do the job."
  290.         ;;
  291.     /*)
  292.         if test -r $termlib
  293.         then
  294.             echo "Ok, we will try that one."
  295.         else
  296.             echo "$termlib does not appear to exist."
  297.             termlib="try_again"
  298.         fi
  299.         ;;
  300.     *)
  301.         echo "$termlib is not a valid library specification."
  302.         termlib="try_again"
  303.         ;;
  304.     esac
  305. done
  306.  
  307. : 'termcap database, commented out for 4.3 BSD'
  308. #echo " "
  309. #if test -r /etc/termcap
  310. #then
  311. #    termcap="yes"
  312. #    echo "Termcap database found."
  313. #else
  314. #    termcap="no"
  315. #    echo "No termcap database found; we will install our own, to be used"
  316. #    echo "when your TERMCAP environment variable is not set."
  317. #fi
  318.  
  319.  
  320. : 'Shall we make B public?'
  321. public="no"
  322. echo " "
  323. echo $n "Will you want to make B publically available? "
  324. read ans
  325. case $ans in
  326. y*|Y*)
  327. public="yes"
  328. if test -r answers
  329. then
  330.     . answers
  331. else
  332.     bdef="/usr/new"
  333.     libdef="/usr/new/lib/B"
  334.     man1def="/usr/man/mann"
  335.     man5def="/usr/man/mann"
  336. fi
  337. bdir='blurfl'
  338. while test ! -d "$bdir" ; do
  339.     case $bdir in
  340.     blurfl)
  341.         echo " "
  342.         echo "Please type the full pathname of a directory"
  343.         echo "in which you have write permission,"
  344.         echo "and where you want the 'b' command file installed"
  345.         echo $n " (default $bdef) "
  346.         ;;
  347.     *)     echo "$bdir does not appear to exist."
  348.         echo $n "Are you sure you typed the right name? "
  349.         read ans
  350.         case $ans in
  351.         y*|Y*)    echo "Don't forget to make $bdir before 'make install'."
  352.             break
  353.             ;;
  354.         *)    echo " "
  355.             echo $n "Please try again (default $bdef) "
  356.             ;;
  357.         esac
  358.         ;;
  359.     esac
  360.     read bdir
  361.     case $bdir in
  362.     "") bdir=$bdef;;
  363.     esac
  364. done
  365. libdir='blurfl'
  366. while test ! -d "$libdir" ; do
  367.     case $libdir in
  368.     blurfl)
  369.         echo " "
  370.         echo "Please type the full pathname of the directory"
  371.         echo "where you want to install the auxiliary binaries"
  372.         echo "and datafiles needed by the B system"
  373.         echo $n " (default $libdef) "
  374.         ;;
  375.     *)     echo "$libdir does not appear to exist."
  376.         echo $n "Are you sure you typed the right name? "
  377.         read ans
  378.         case $ans in
  379.         *|Y*)    echo "Don't forget to make $libdir before 'make install'."
  380.             break
  381.             ;;
  382.         *)    echo " "
  383.             echo $n "Please try again (default $libdef) "
  384.             ;;
  385.         esac
  386.         ;;
  387.     esac
  388.     read libdir
  389.     case $libdir in
  390.     "") libdir=$libdef;;
  391.     esac
  392. done
  393. man1dir='blurfl'
  394. while test ! -d "$man1dir" ; do
  395.     case $man1dir in
  396.     blurfl)
  397.         echo " "
  398.         echo "Please type the full pathname of the directory"
  399.         echo "where you want to install the 'b.1' manual page"
  400.         echo $n " (default $man1def) "
  401.         ;;
  402.     *)     echo "$man1dir does not appear to exist."
  403.         echo $n "Are you sure you typed the right name? "
  404.         read ans
  405.         case $ans in
  406.         y*|Y*)    echo "Don't forget to make $man1dir before 'make install'."
  407.             break
  408.             ;;
  409.         *)    echo " "
  410.             echo $n "Please try again (default $man1def) "
  411.             ;;
  412.         esac
  413.         ;;
  414.     esac
  415.     read man1dir
  416.     case $man1dir in
  417.     "") man1dir=$man1def;;
  418.     esac
  419. done
  420. man5dir='blurfl'
  421. while test ! -d "$man5dir" ; do
  422.     case $man5dir in
  423.     blurfl)
  424.         echo " "
  425.         echo "Please type the full pathname of the directory"
  426.         echo "where you want to install the 'bterminal.5' manual page"
  427.         echo $n " (default $man5def) "
  428.         ;;
  429.     *)     echo "$man5dir does not appear to exist."
  430.         echo $n "Are you sure you typed the right name? "
  431.         read ans
  432.         case $ans in
  433.         y*|Y*)    echo "Don't forget to make $man5dir before 'make install'."
  434.             break
  435.             ;;
  436.         *)    echo " "
  437.             echo $n "Please try again (default $man5def) "
  438.             ;;
  439.         esac
  440.         echo $n "Please try again "
  441.         ;;
  442.     esac
  443.     read man5dir
  444.     case $man5dir in
  445.     "") man5dir=$man5def;;
  446.     esac
  447. done
  448.  
  449. cat >answers <<EOF
  450. bdef="$bdir"
  451. libdef="$libdir"
  452. man1def="$man1dir"
  453. man5def="$man5dir"
  454. EOF
  455. ;;
  456. esac
  457. echo " "
  458. echo "End of configuration questions for the B system."
  459.  
  460. : 'Getting generic copies of makefiles and shellfiles.'
  461. : 'Since some tar_s leave the owner of the tape as the owner of the files'
  462. : 'this will make sure the edit scripts will not fail.'
  463.  
  464. makefiles="./Makefile src/b/Makefile src/bed/Makefile src/bint/Makefile src/bsmall/Makefile"
  465. shellfiles="src/b/b.sh src/b/b_p.sh"
  466.  
  467. editor="ed -"
  468.  
  469. cat >mf.head <<EOF
  470. # This file was generated and edited by the Setup command.
  471. # To make lasting changes edit the file Makefile.gen and run Setup again.
  472. EOF
  473. for f in $makefiles
  474. do
  475.     cat mf.head $f.gen >$f
  476.     chmod 644 $f
  477. done
  478. rm -f mf.head
  479.  
  480. for f in $shellfiles
  481. do
  482.     cp $f.gen $f
  483.     chmod 755 $f
  484. done
  485.  
  486. echo " "
  487. echo $n "Editing Appropriate files ... "
  488.  
  489. case $machine in
  490. pdp)
  491.     f=src/bed/Makefile
  492.     $editor $f <<EOF
  493.     /^LDFLAGS=/s?LDFLAGS=.*?LDFLAGS= -i?
  494.     w
  495.     q
  496. EOF
  497.     f=src/bsmall/Makefile
  498.     $editor $f <<EOF
  499.     /^LDFLAGS=/s?LDFLAGS=.*?LDFLAGS= -i?
  500.     w
  501.     q
  502. EOF
  503.     ;;
  504. esac
  505.  
  506. : 'Not all CFLAGS are used by all sources.'
  507. : 'But for convenience and future use, we put them into all source Makefiles.'
  508.  
  509. cflags="-O $fflag -DNDEBUG"
  510.  
  511. for f in Makefile src/b/b.sh src/bed/Makefile
  512. do
  513.     $editor $f <<EOF
  514.     /^BINT=/s?BINT=.*?BINT=$bint?
  515.     w
  516.     q
  517. EOF
  518. done
  519.  
  520. case $bint in
  521. bsmall)
  522.     f=Makefile
  523.     $editor $f <<EOF
  524.     /examples$/s?make .*examples?make smallexamples?
  525.     w
  526.     q
  527. EOF
  528.     cflags="$cflags -DSMALLSYS"
  529.     ;;
  530. esac
  531.  
  532. case $unix in
  533. BSD|BSD4_2|PWB)
  534.     cflags="$cflags -D$unix"
  535.     ;;
  536. ATT)
  537.     cflags="$cflags -Dindex=strchr -Drindex=strrchr"
  538.     ;;
  539. esac
  540.  
  541. case $termio in
  542. yes)
  543.     cflags="$cflags -DTERMIO"
  544.     ;;
  545. esac
  546.  
  547. for f in src/b/Makefile src/bed/Makefile src/$bint/Makefile
  548. do
  549.     $editor $f <<EOF
  550.     /^CFLAGS=/s?CFLAGS=.*?CFLAGS= $cflags?
  551.     w
  552.     q
  553. EOF
  554. done
  555.  
  556. case $termlib in
  557. -l*|/*)
  558.     f=src/bed/Makefile
  559.     $editor $f <<EOF
  560.     /^TERMLIB=/s?.*?TERMLIB= $termlib?
  561.     /^OWNTLIB=/s?.*?OWNTLIB=?
  562.     w
  563.     q
  564. EOF
  565.     ;;
  566. libtermcap.a)
  567.     f=src/bed/Makefile
  568.     $editor $f <<EOF
  569.     /^TERMLIB=/s?.*?TERMLIB=?
  570.     /^OWNTLIB=/s?.*?OWNTLIB= libtermcap.a?
  571.     w
  572.     q
  573. EOF
  574.     ;;
  575. esac
  576.  
  577. #case $termcap in
  578. #no)
  579. #    f=src/b/Makefile
  580. #    $editor $f <<"EOF"
  581. #    /^install:/s?.*?install:    all ldest termcap?
  582. #    w
  583. #    q
  584. #EOF
  585. #    ;;
  586. #esac
  587.  
  588. case $public in
  589. yes)
  590.     f=Makefile
  591.     $editor $f <<EOF
  592.     /^BDIR=/s?BDIR=.*?BDIR=$bdir?
  593.     /^MAN1DIR=/s?MAN1DIR=.*?MAN1DIR=$man1dir?
  594.     /^MAN5DIR=/s?MAN5DIR=.*?MAN5DIR=$man5dir?
  595.     /^LIBDIR=/s?LIBDIR=.*?LIBDIR=$libdir?
  596.     w
  597.     q
  598. EOF
  599.     ;;
  600. esac
  601.  
  602. echo "done."
  603.  
  604. echo " "
  605. echo "This completes the setup of the B system."
  606. echo "You can now try 'make all'."
  607.